From 67dcca0adbdde919b645124745aa8987e1c6eea2 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 26 Mar 2025 10:25:58 +0100 Subject: [PATCH] gui/macOS: Ensure file provider domain progress instances are correctly retained Signed-off-by: Claudio Cambra --- src/gui/macOS/progressobserver.m | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/gui/macOS/progressobserver.m b/src/gui/macOS/progressobserver.m index b52e13b26..f6b6aaad0 100644 --- a/src/gui/macOS/progressobserver.m +++ b/src/gui/macOS/progressobserver.m @@ -21,6 +21,7 @@ self = [super init]; if (self) { _progress = progress; + [_progress retain]; [_progress addObserver:self forKeyPath:@"totalUnitCount" options:NSKeyValueObservingOptionNew context:nil]; [_progress addObserver:self forKeyPath:@"completedUnitCount" options:NSKeyValueObservingOptionNew context:nil]; [_progress addObserver:self forKeyPath:@"cancelled" options:NSKeyValueObservingOptionNew context:nil]; @@ -31,6 +32,18 @@ return self; } +- (void)dealloc +{ + [_progress removeObserver:self forKeyPath:@"totalUnitCount"]; + [_progress removeObserver:self forKeyPath:@"completedUnitCount"]; + [_progress removeObserver:self forKeyPath:@"cancelled"]; + [_progress removeObserver:self forKeyPath:@"paused"]; + [_progress removeObserver:self forKeyPath:@"fileTotalCount"]; + [_progress removeObserver:self forKeyPath:@"fileCompletedCount"]; + [_progress release]; + [super dealloc]; +} + - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change -- 2.30.2